# -*- codeing = utf-8 -*-

from django import forms

from analysis import models
from analysis.forms.bootstrap import BootStrap


class addSingCase(BootStrap, forms.ModelForm):
    """ 新增case页面"""
    cmd = forms.CharField(label='用例名称',
                          error_messages={
                              'required': '用户名不能为空',
                          })
    comment = forms.CharField(label='备注',)

    def clean_cmd(self):
        cmd = self.cleaned_data.get('cmd')
        is_exist = models.BaseData.objects.filter(cmd).exists()
        if is_exist:
            self.add_error('用例已存在')
        return cmd

    class Meta:
        model = models.BaseData
        fields = ['cmd','comment']
